home *** CD-ROM | disk | FTP | other *** search
- property sp, cst, pos, state, hitCounter, TVPicList, TVtimer, flickerTimer, lightTimer, greetCherubObj
-
- on new me, asp
- me.sp = asp
- puppetSprite(me.sp, 1)
- sprite(me.sp).visible = 1
- me.cst = the member of sprite me.sp
- me.pos = the loc of sprite me.sp
- me.state = #noise
- TVPicList = []
- makeList(me, TVPicList, "TV")
- me.hitCounter = 0
- return me
- end
-
- on CheckState me
- case me.state of
- #noise:
- FlickPics(me, TVPicList)
- #thumped:
- CountHits(me)
- #Flicker:
- Flicker(me)
- #working:
- me.state = #greeting
- SwapCast(me, member("TreeLights"))
- greetCherubObj = new(script("GreetingCherub Parent"), me.sp + 2)
- #greeting:
- FlashLights(me)
- CheckState(greetCherubObj)
- end case
- end
-
- on FlickPics me, aList
- if the timer > TVtimer then
- tempPos = getOne(aList, me.cst)
- tempCast = random(count(aList))
- if tempCast = tempPos then
- FlickPics(me, TVPicList)
- else
- CueTVTimer(me, 3)
- SwapCast(me, getAt(aList, tempCast))
- end if
- end if
- end
-
- on FlashLights me
- if the timer > lightTimer then
- CueLightTimer(me, 10)
- if sprite(me.sp).visible = 0 then
- sprite(me.sp).visible = 1
- else
- sprite(me.sp).visible = 0
- end if
- end if
- end
-
- on CueLightTimer me, aNum
- lightTimer = the timer + aNum
- end
-
- on CueTVTimer me, aNum
- TVtimer = the timer + aNum
- end
-
- on CountHits me
- me.hitCounter = me.hitCounter + 1
- CueflickerTimer(me, 60)
- me.state = #Flicker
- end
-
- on Flicker me
- if the timer > flickerTimer then
- case hitCounter of
- 3:
- sprite(me.sp).visible = 0
- me.state = #working
- otherwise:
- sprite(me.sp).visible = 1
- me.state = #noise
- end case
- else
- temp = random(5)
- case temp of
- 1:
- sprite(me.sp).visible = 0
- otherwise:
- sprite(me.sp).visible = 1
- end case
- end if
- end
-
- on CueflickerTimer me, aNum
- flickerTimer = the timer + aNum
- end
-
- on makeList me, aList, aName
- repeat with x = 1 to the maxinteger
- if the number of member (aName & x) > 0 then
- add(aList, member(aName & x))
- next repeat
- end if
- exit repeat
- end repeat
- end
-
- on SwapCast me, aMem
- me.cst = aMem
- set the member of sprite the sp of me to me.cst
- end
-
- on DrawtoStage me
- set the loc of sprite the sp of me to me.pos
- end
-